﻿using Smobiler.Core;
using Smobiler.Core.Controls;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DAL;
using Model;

namespace FubiManger.UI
{
    partial class IntegralForm : Smobiler.Core.Controls.MobileForm
    {
        public IntegralForm() : base()
        {
            //This call is required by the SmobilerForm.
            InitializeComponent();
        }
        /// <summary>
        /// 商户ID
        /// </summary>
        public string merchantid { get; set; }
        int integral = 0;
        private void panclose_Press(object sender, EventArgs e)
        {
            this.Close();
        }

        private void IntegralForm_Load(object sender, EventArgs e)
        {

            ms_merchant merchant = merchantDal.Querybyid(merchantid);//商家信息
            lblmarketing_funds.Text = merchant.marketing_funds;//营销金额
            integral = integral_ruleDal.Querybymerid(merchantid);//积分金额
            txtintegral.Text = integral.ToString();//积分金额
        }

        private void pansave_Press(object sender, EventArgs e)
        {
            try
            {
                if (Convert.ToInt32(txtintegral.Text) >= 20)
                {
                    if (integral == 0)
                    {
                        if (integral_ruleDal.Addreul(merchantid, txtintegral.Text) > 0)
                            Toast("金赑规则创建成功");
                    }
                    else
                    {
                        if (integral_ruleDal.Update(merchantid, txtintegral.Text) > 0)
                            Toast("金赑规则更新成功");
                    }
                }
                else
                {
                    MessageBox.Show("请输入大于等于20的正数");
                }
            }
            catch (Exception)
            {

                MessageBox.Show("请输入大于等于20的正数");
            }
        }
    }
}